import faker
import faker.providers.date_time
from faker import Faker
import random

class Data():

    fake = Faker('zh_CN')  # 使用中文本地化

    def generate_name(self):
        return self.fake.name()

    def generate_id_number(self):
        # 生成18位身份证号码
        prefix = random.choice(['110', '120', '130', '140'])  # 随机选择一个地区前缀
        middle = ''.join(random.choices('0123456789', k=14))  # 生成中间14位数字
        return f"{prefix}{middle}"

    def generate_phone_number(self):
        return self.fake.phone_number()

    def generate_random_number(self):
        rand_num = random.randint(1000, 9999)  # 生成一个4位的随机数
        return str(rand_num)


if __name__ == '__main__':
    # 生成数据
    data = Data()
    name = data.generate_name()
    id_number = data.generate_id_number()
    phone_number = data.generate_phone_number()
    num = data.generate_random_number()

    print(f"姓名: {name}")
    print(f"身份证号码: {id_number}")
    print(f"电话号码: {phone_number}")
    print(f"随机数: {num}" )
